ferrusfandomcom-20200214-history
Character Architecture
The ACommissarCharacter class is the main class from which all characters are derived. Whether or not it uses AI routines is defined by a single boolean value, bIsPlayer (set to false for AI, obviously). It is intended to be blueprinted. Attributes and skills which are shared by NPCs/the player (or are NPC only) are modifiable via Blueprint for the sake of configuring multiple different types of characters easily. However, runtime modifications are done only via setter/getter methods - this applies to all other attributes, too. Attribute Logic Attributes take the form of floating point values, integers and strings, and form the basis of the character's abstract architecture. Simply put, they are: * Health/Max health: Integer values. The former stores current health, the latter maximum. Default for maximum/health is 100. Public values, blueprint editable. ** Modified by: ACommissarWieldableItem, ACommissarWearableItem, physics impact, physics volumes, ACommissarConsumableItem, self * Shields/Max shields: A value derived from the player's currently configured rig. It is gained via the currently referenced instance of ACommissarWearableItem on initialisation, and then the character class references the value in public & private members: int Shields, int MaxShields respectively. The initial value is editable in the Wearable's blueprint. ** Modified by: ACommissarWieldableItem, ACommissarWearableItem, ACommissarConsumableItem * Maximum movement speed: This determines how many units per tick the character moves at maximum. It's the variable float DefaultMaxWalkingSpeed, inherited from AActor. ** Modified by: self, ACommissarWearableItem * Jumping variables: See default CharacterMovement component. ** Modified by: self, ACommissarWearableItem ----------------------------------------------------------------------------------------------- Innate Inventory Variables * Currently Held Item: Pointer to an instance of class ACommissarWieldableItem. ** Modified by: self * Currently Worn Item: Pointer to an instance of class ACommissarWearableItem. ** Modified by: self * Credits/Max Credits: Pair of integers, similar to health in function. ** Modified by: self * Matter/Max Matter: Pair of integers, similar to health in function. ** Modified by: self, ACommissarWearableItem ----------------------------------------------------------------------------------------------- Character Weapon Modifiers * Base Weapon Spread Reduction: A floating point value which reduces a character's weapon spread modifier over time. Clamped between a maximum and a minimum value. * Base Weapon Reload Speed: A floating point value which modifies how fast a character's reload animation is played. * Base Melee Hit Speed: A floating point value which determines how fast a melee attack animation is played. * Base Melee Hit Strength: A floating point value which modifies a melee weapon's damage on hit. * Weapon Spread/Max Weapon Spread: A pair of floating point values used to modify a projectile's initial vector. Only applies to single/cluster projectiles, not waves or lines. Skill Logic Skills are organised into a basic class, CommissarBaseSkill, which come with both basic, universal attributes as well as unique effects and modifiers. A generic skill looks as follows: * Struct of type class Skill * string FriendlyName: Used for displaying in the UI * string SystemName: Used for reference by the system * string UntrainedDescription: Human-friendly description for the skill at Untrained. * string TrainedDescription: Human-friendly description for the skill at Trained. * string AdvancedDescription: Human-friendly description for the skill at Expert. * string MasterDescription: Human-friendly description for the skill at Master. * int ExperienceCost: How much XP the skill costs at base. * int ExperienceCostModifier: How much XP the skill cost is increased by each level. * int CurrentLevel: An integer from 1 to 4 describing what level this skill is at. * Material IconLarge: A 128x128px icon. PNG format. * Material IconSmall: A 32x32px icon. PNG format. The base class is subclassed, and then a character type maintains a reference to an array of skills available to them. Equipment Logic Equipment is maintained as a set of pointers to instances of blueprints in memory. Movement Logic Outline: All characters in Ferrus: Commissar share movement logic by way of ACommissarCharacter; they can all sprint, run, walk, crouch and jump in atmosphere, but fly and dash in zero gravity. * Walking: Hold down a key, or toggle, to move at a third of the character's running speed. It reduces noise and adds a minor stabilisation bonus to your currently held firearm. Allows the user's weapon spread to reduce by half its normal speed. * Running: Default movement. This is the measuring post for noise generation and firearm accuracy. * Sprinting: Hold down a key, or toggle, to move at double the character's running speed. It increases noise and penalises weapon stability. Does not allow for the reduction of weapon spread. * Crouching: Hold down a key, or toggle, to move at 1/4 of the character's running speed. Generates the lowest amount of noise, and stabilises the user's aim to minimum spread fastest at 1.25 the speed. * Jumping: Temporarily launch yourself from the ground with a button press. Combine with a directional key to jump in that direction, otherwise jump straight up. * (Zero-G) Flying: Move at half running speed in any direction. Letting go of a directional control leaves the player drifting in the direction they last accelerated in. The character listens to control input in its Tick() method, altering the character's state by switching (int) CurrentState to the corresponding state enumerator value. Jumping and Crouching are monitored by the engine itself by default for the ACharacter class (and its descendants), so this enumerator only tracks those 4 states. In addition, it also monitors the following generic states: Character Inventory A character's inventory is a TArray containing pointers to items of type ACommissarItem, allowing the array to contain its subclassed Wieldable and Consumable items. Graphically, it is represented as a grid, with the inventory item containing an integer marking how many grids it takes up, as well as the position of the upper leftmost square for purposes of rendering the object in the inventory, and having the necessary collision detection in place so that items can not overlap. Quick Select Inventory: This is an index in the item's code which is changed whenever the user assigns the item to a quick select slot, ranging from 1 to 10 (represented as 0). Matter Programmer: The matter programmer itself does not take up a space in the player's inventory (by virtue of being an armor component), but anything produced in it will look for a free spot in the menu. If there is none, it's dropped to the floor with an audio cue.